package com.neuronbit.businessflow.flow.source.util;

import com.neuronbit.businessflow.flow.source.*;
import com.neuronbit.businessflow.intellij.model.Node;

/**
 * The type Step java source factory.
 */
public class StepJavaSourceFactory {

    /**
     * Instantiates a new Step java source factory.
     */
    public StepJavaSourceFactory() {
    }

    /**
     * Create node source java source.
     *
     * @param node          the node
     * @param sourceContext the source context
     * @return the java source
     */
    public static JavaSource createNodeSource(Node node, SourceContext sourceContext) {
        switch (node.getNodeType()) {
            case START:
                return new StartStepJavaSource(node, sourceContext);
            case END:
                return new EndStepJavaSource(node, sourceContext);
            case JOIN:
                return new JoinStepJavaSource(node, sourceContext);
            case FORK:
                return new ForkStepJavaSource(node, sourceContext);
            case DECISION:
                return new DecisionStepJavaSource(node, sourceContext);
            case SWITCH_TASK:
                return new SwitchTaskStepJavaSource(node, sourceContext);
            case AUTO_TASK:
                return new AutoTaskStepJavaSource(node, sourceContext);
            case STATEFUL_TASK:
                return new StatefulTaskStepJavaSource(node, sourceContext);
            default:
                throw new IllegalArgumentException("Unsupported node type: " + node.getNodeType());
        }
    }
}
